package com.example.callcenter.controller;

import com.example.callcenter.dto.LoginDTO;
import com.example.callcenter.service.AuthService;
import com.example.callcenter.util.ResultUtil;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;



@RestController
@RequestMapping("/auth")
public class AuthController {

    @Autowired
    private AuthService authService;

    @PostMapping("/login")
    public ResultUtil login(@Valid @RequestBody LoginDTO loginDTO) {
        return authService.login(loginDTO);
    }

    @PostMapping("/refresh-token")
    public ResultUtil refreshToken(@RequestBody String refreshToken) {
        return authService.refreshToken(refreshToken);
    }
}